Repository navigation
Conversation
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 0f640d0. Bugbot is set up for automated code reviews on this repo. Configure here. |
…oved epoch synchronization and cache handling
| } | ||
| } else { | ||
| $this->writeStoreEntry($key, $value); | ||
| } |
There was a problem hiding this comment.
Stale resolve can overwrite Redis
High Severity
resolve() re-checks the epoch before writing Redis, but the write itself is not guarded. A concurrent saved()/set() can bump the epoch and publish a committed value in the gap between forceResyncEpoch() and writeStoreEntry(), so a loader that still holds a pre-commit row overwrites L2 under the new epoch. Later workers then hit that stale envelope and never go back to the database until the setting is saved again.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 13d40b1. Configure here.
| if (method_exists($settingCache, 'publishEpoch')) { | ||
| $settingCache->publishEpoch(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Epoch publish runs before commit
Medium Severity
The new saved() hook comments that it publishes the L1 epoch after the row is committed, but it listens to Eloquent saved without afterCommit. Inside a wrapping DB::transaction(), that still runs before commit, so concurrent byKey() loaders can refill Redis with the pre-commit row after the epoch bump.
Reviewed by Cursor Bugbot for commit 13d40b1. Configure here.
| self::$localEpochs[$tenantKey] = $newEpoch; | ||
| self::$epochUnreliable[$tenantKey] = false; | ||
| self::$syncedThisRequest[$tenantKey] = true; | ||
| } |
There was a problem hiding this comment.
Failed epoch bump marked reliable
Medium Severity
bumpEpoch() always sets epochUnreliable to false and syncedThisRequest to true, even when incrementRemoteEpoch() fails both INCR and SET. The publishing worker then treats L1/L2 as trustworthy although other workers never saw an epoch change and keep serving stale memory.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 13d40b1. Configure here.
| public static function put(string $key, mixed $value): void | ||
| { | ||
| $tenantKey = self::currentTenantKey(); | ||
| self::$items[$tenantKey][$key] = $value; |
There was a problem hiding this comment.
L1 cache shares mutable setting models
Medium Severity
Setting::byKey() now returns the live L1 object rather than a deserialized copy. In-place changes to that model or its nested config object stay in the worker map and are reused on later byKey() calls until an epoch bump. Callers such as CSS override and settings upload mutate the instance from byKey() before save().
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 284c671. Configure here.
|
QA server K8S was successfully deployed https://tenant-1.ci-8c8b0bf840.engk8s.processmaker.net |
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
There are 5 total unresolved issues (including 4 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0f640d0. Configure here.
| } | ||
|
|
||
| $value = $this->loadAndPublish($key, $loader, $epochAtStart); | ||
| SettingMemoryCache::put($key, $value); |
There was a problem hiding this comment.
Unreliable resolve fills worker L1
Medium Severity
When the epoch read after the loader fails, loadAndPublish returns without fencing, but resolveCacheMiss still puts that value into L1. The next request on the same worker keeps that map if the epoch is unchanged, so a stale or pre-commit setting can be served from memory instead of Redis or the database.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 0f640d0. Configure here.
| return $value; | ||
| } | ||
|
|
||
| if (SettingMemoryCache::localEpoch() !== $epochAtStart) { |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: SettingObserver::saved() drops the Redis settings key and publishEpoch() inside an open outer transaction. The observer does not use afterCommit, so Eloquent saved runs when the model is written, before DB::transaction commits. A concurrent worker that then resolves that key sees the new epoch, misses Redis, and loadAndPublish() stores loader()'s SELECT. On the default MySQL InnoDB connection that SELECT cannot see the writer's uncommitted row, so writeStoreEntry() persists the previous row with no TTL under the new epoch. DevLinkInstall keeps the transaction open across Bundle::installSettingsPayloads(), which updateOrCreate()s Log-In & Auth settings and never calls SettingCacheManager::set() after the outer commit. RefreshArtisanCaches::handle() is empty, so the terminating refresh does not remove the refilled key. Later Setting::byKey and SettingsConfigRepository reads keep serving the previous password-policy, 2FA, SSO, and session-control values. SettingController::update() does call set() with the refreshed model after save(), so that direct API write publishes the committed row.
Impact: A committed bundle install can leave 2FA, password policy, SSO/login, and session IP/device restrictions at the previous value for every worker until some later epoch bump. Login and session middleware keep enforcing that stale policy. The refill is any overlapping settings read during the install transaction; the poisoned Redis entry then applies to unauthenticated login traffic. This needs an in-flight privileged install, so it is not a scriptable unauthenticated attack on its own, and it does not grant full control of the app.
Remediation: Run epoch publish and the Redis write from DB::afterCommit (observer $afterCommit / ShouldHandleEventsAfterCommit, or an explicit afterCommit callback), and only after the committed value is stored. In loadAndPublish(), when the epoch moved or the key is missing after a bump, do not writeStoreEntry() the loader result; return it for this call and leave Redis empty so a pre-commit snapshot cannot become the authoritative entry. Bundle and DevLink setting writes should set() the committed model in that after-commit hook.
| return $value; | ||
| } | ||
|
|
||
| if (SettingMemoryCache::localEpoch() !== $epochAtStart) { |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: loadAndPublish() can publish a pre-update Setting row to Redis after the shared epoch has already moved, so other workers treat the old password-policy, 2FA, session-control, or default-SSO value as current.
Impact: Login and session requests call Setting::byKey/config() with no credentials (login throttling, 2FA, sso.default.login, session-control.ip_restriction/device_restriction). A fill that lands after saved()/set() stamps the previous row at the new epoch. The next worker syncs to that epoch, hits Redis, and enforces the old policy with no DB read until some later epoch bump. The saving worker still keeps the new value in its own L1 after set(), so the admin node looks updated while the others do not. The wide window is an outer transaction: SettingObserver::saved() forgets the key and bumps the epoch before commit and is not afterCommit, and DevLink install of Log-In & Auth settings never calls set() after commit, so any overlapping byKey writes the snapshot that other connections cannot see yet. The narrow window is set() itself: the epoch GET and the later SET are separate Redis commands, so a resolver that still observed the old epoch can overwrite the committed payload after bumpEpoch().
Remediation: Write a fill only with a Redis compare-and-set on the epoch observed before loader() (Lua or WATCH/MULTI). If the epoch changed, do not writeStoreEntry(); return a store hit when one exists, otherwise return loader() to this caller only. Bump and publish only a value read after the commit that produced the bump. Set SettingObserver::$afterCommit = true (or publish the epoch from DB::afterCommit) so saved() does not invalidate inside an open transaction.
| /** | ||
| * Atomically increment the shared epoch; on failure, seed with $fallback. | ||
| */ | ||
| public static function incrementOrFallback(int $fallback): int |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
Description: SettingEpochRedis::incrementOrFallback() treats a failed epoch INCR as a successful publish: it logs, may SET the caller's localEpoch+1 over the shared key, and always returns that fallback. SettingMemoryCache::bumpEpoch() then clears only the publishing worker's L1 and records epochUnreliable=false and syncedThisRequest=true. Peer workers invalidate solely by observing a higher Redis epoch, so an unchanged or rewound epoch leaves their existing L1 entries in place. resolve() then returns those entries and does not hit Redis or the database.
Impact: The shared epoch is the only cross-worker freshness gate for process-local settings L1. After a committed setting save, a publisher-side INCR failure (timeout, connection reset, OOM, or READONLY on the epoch write) while peer GETs still succeed leaves other Octane or queue workers enforcing the previous value. Session IP and device restrictions are read through Setting::configByKey on each login check, and SSO default login is read through Setting::byKey, so those workers can keep allowing sessions the new policy was meant to block. A fallback SET can also move the shared counter backward when the publisher's localEpoch is behind, so workers already sitting on that lower value never invalidate. A total epoch GET failure still fail-closes the worker that sees it; this gap is the swallowed write path, and it is not attacker-scriptable.
Remediation: Do not return or SET a locally computed epoch when INCR fails. Leave the publisher epochUnreliable so its own later reads skip L1, and do not mark syncedThisRequest. Only advance the shared counter with INCR (or a compare-and-set that refuses a lower value). Peers should drop L1 unless a successful GET shows an epoch greater than the one they cached with the entry.






[Perf 2026.17] Review the perfomance across all the plataform
Related Tickets & Packages
Code Review Checklist
ci:deploy
ci:run-testbench
.